/**
 * 
 */
package com.witframework.meta;

import java.util.HashMap;
import java.util.Map;

import com.witframework.components.SelectOptions;

/**
 * @author wuxinyang
 * Jun 11, 2009 9:44:07 AM
 * 
 */
public class EntityFieldType implements SelectOptions {
	static String STRING="String";
	static String NUMERIC="Numeric";	
	static String DATE="Date";
	static String TIME="Time";
	static String TIMESTAMP="TimeStamp";
	static String BOOLEAN="Bolean";	
	static String BLOB="Blob";
	static String CLOB="Clob";
	static String REF="Ref";
	static Map<String,String> fields=new HashMap<String,String>();
	static{
		fields.put("文本",STRING);
		fields.put("数值",NUMERIC);		
		fields.put("日期",DATE);
		fields.put("时间",TIME);
		fields.put("时间戳",TIMESTAMP);
		fields.put("大文本",BLOB);
		fields.put("文件",CLOB);
		fields.put("布尔",BOOLEAN);
		fields.put("引用",REF);		
	}
	/* (non-Javadoc)
	 * @see com.witframework.components.SelectOptions#getOptionsMap()
	 */
	public Map<String, String> getOptionsMap() {		
		return fields;
	}
	public static String getJavaTypeName(String typeName){
		if(typeName.equals(STRING))
			return "String";
		else if(typeName.equals(NUMERIC))
			return "Double";		
		else if(typeName.equals(DATE)||typeName.equals(TIME)||typeName.equals(TIMESTAMP))
			return "java.util.Date";
		else if(typeName.equals(BOOLEAN))
			return "Boolean";		
		else if(typeName.equals(BLOB))
			return "String";
		else if(typeName.equals(CLOB))
			return "byte[]";	
		return typeName;
	}
	public static String getJavaTypeName(String typeName,int precision){
		if(typeName.equals(NUMERIC)&&precision==0)
			return "Integer";
		else
			return "Double";		
	}
	public static String getDMTypeName(String typeName){
		if(typeName.equals(STRING))
			return "VARCHAR";
		else if(typeName.equals(NUMERIC))
			return "NUMERIC";		
		else if(typeName.equals(DATE))
			return "DATE";
		else if(typeName.equals(BOOLEAN))
			return "VARCHAR";		
		else if(typeName.equals(BLOB))
			return "BLOB";
		else if(typeName.equals(CLOB))
			return "CLOB";	
		return "VARCHAR";
	}

}
